package com.share.chat.listener;

/**
 * @author 谢佳豪
 * @data 2021/1/20 - 1:22
 * @description
 */

import org.springframework.stereotype.Component;

import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpServletRequest;


/**
 * 监听器类:主要任务是用ServletRequest将我们的HttpSession携带过去
 * @author 谢佳豪
 */
@Component
public class RequestListener implements ServletRequestListener {
    @Override
    public void requestInitialized(ServletRequestEvent sre)  {

        //将所有request请求都携带上httpSession
        ((HttpServletRequest) sre.getServletRequest()).getSession();
    }
    public RequestListener() {}

    @Override
    public void requestDestroyed(ServletRequestEvent arg0)  {}
}
